Add cel-expr-python backend#485
Conversation
|
While I have some reservations, we have decided to go with this approach - we'll see if issues come up going forward. To make it easier to rethink, I have kept the implementations largely separate - anyways, the CEL APIs being quite different necessitates a lot of the general control flow duplication, and it would get quite surgical to try to extract common logic bits. We can reconsider in the future if things settle |
| # protobuf 7+ removed FieldDescriptor.label / LABEL_REPEATED in favour of is_repeated. | ||
| _FieldDescriptorClass = google_descriptor.FieldDescriptor | ||
| if hasattr(_FieldDescriptorClass, "is_repeated"): | ||
|
|
||
| def _is_repeated(field: google_descriptor.FieldDescriptor) -> bool: | ||
| return field.is_repeated | ||
|
|
||
| else: | ||
|
|
||
| def _is_repeated(field: google_descriptor.FieldDescriptor) -> bool: | ||
| return field.label == google_descriptor.FieldDescriptor.LABEL_REPEATED |
There was a problem hiding this comment.
We're doing the same thing in rules.py - can we just import it from there?
There was a problem hiding this comment.
Yeah extracted to a util
| @@ -0,0 +1,1686 @@ | |||
| # Copyright 2023-2026 Buf Technologies, Inc. | |||
There was a problem hiding this comment.
Most of this file appears to be duplicated from internal/extra_func.py.
There was a problem hiding this comment.
Thanks - at first I thought there was at least a need for structural duplication since the cel types are different for the two libraries, and thought sharing logic would get complicated then. I realized a simple argument wrapper on the celpy side avoids both duplication and surgery, just a couple of functions left that are not matches between the two
This adds an implementation using cel-expr-python. It is much faster, orders of magnitude, but has many gotchas. This is currently a rough draft PR to show the concept and list up what it means